<template>
	<om-page title="图片预览">
		<om-sub title="图片预览">
			<view class="flex justify-center align-center">
				<image :src="fileUrl" mode="widthFix" @click="imageClick" style="border:2px solid #ddd"></image>
				<!-- <ot-cropper :src="cropperUrl" :showCropper="false" @cancel="cancel"></ot-cropper> -->
			</view>
		</om-sub>
	</om-page>
</template>

<script>
	export default {
		data() {
			return {
				fileUrl:"",
				cropperUrl:""
			}
		},
		methods: {
			imageClick(){
				uni.previewImage({
					urls:[this.fileUrl],
					current:0
				})
				// this.cropperUrl = this.fileUrl
			},
			cancel() {
				this.cropperUrl="";
			}
		},
		onLoad(e) {
			if(e.url){
				this.fileUrl = e.url
				if(e.fileId){
					if(this.fileUrl.indexOf("?")){
						this.fileUrl += "&fileId="+e.fileId
					}else{
						this.fileUrl += "?fileId="+e.fileId
					}
				}
			}else{
				let _that = this
				uni.getStorage({
					key:"image-cache",
					success:function(res){
						if(res.data){
							_that.fileUrl = res.data
						}
						uni.removeStorage({
							key:"image-cache"
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>
